﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.ServiceModel;

namespace MF.ServiceModel
{
    [DbContextBehavior]
    public class BaseDbContextService : IDisposable
    {
        #region IDisposable Members

        public void Dispose()
        {
            var dbCtxExtension = OperationContext.Current.InstanceContext.Extensions.Find<DbContextInstanceExtension>();
            if (dbCtxExtension != null)
            {
                dbCtxExtension.Context.Dispose();
                dbCtxExtension.Context = null;
            }
                
        }

        #endregion
    }
}
